package mysqloperate;

import java.sql.Connection;
import java.sql.DriverManager;

public class connection {
    private static String qudong="com.mysql.jdbc.Driver";
    //url格式：jdbc:mysql://ip地址:端口号/数据库名称?额外参数
    private static String url="jdbc:mysql://localhost:3306/managementsql?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8";
    private static String user="root";
    private static String password="031212";

    //连接
    public Connection getconnection()throws Exception{
        Class.forName(qudong);
        Connection connection=DriverManager.getConnection(url,user,password);
        return connection;
    }
        //关闭连接
    public void getclose(Connection con)throws Exception{
        if(con!=null){
            con.close();
        }
    }
}
